package com.ccs.demo;

import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.PrintStream;

@RequestMapping("/new2")
@RestController
public class RequestControllerNew2 {

   @RequestMapping("/getCookieNew2")
   public String getCookieNew2(HttpServletRequest request){
       Cookie[] cookies=request.getCookies();
       if(cookies!=null){
           Cookie[] var=cookies;
           int len=cookies.length;
           for(int i=0;i<len;++i){
               Cookie cookie=var[i];
               PrintStream var1000=System.out;
               String var10001=cookie.getName();
               var1000.println(var10001+ ":" + cookie.getValue());
           }
       }
       return "成功";
   }

    @RequestMapping("/getCookieNew2")
    public String getCookie(@CookieValue String className){
        return "获取cookie成功" + "className:" + className;
    }

}
